export function validateMobile (self) {
  var regu = /[1][0-9]{10}$/;
  var re = new RegExp(regu);
  const _mobile = self.data.mobile
  if (!re.test(_mobile)) {
    self.setData({
      mobileErr: true,
      mobileErrMsg: '填写正确手机号'
    })
    return false;
  }
  return true
}

export function validate () {
  let self = Array.prototype.shift.call(arguments)
  let pass = true
  Array.from(arguments).forEach((item) => {
    if (!self.data[item]) {
      self.setData({
        [item + 'Err']: true
      })
      pass = false
    }
    if (item == 'mobile') {
      pass = validateMobile(self)
    }
  })
  return pass
}